angular.module("app").controller("welfare.list.Ctrl", ["$scope", "welfare", "$state", function ($scope, welfare, $state) {
    $scope.search = { status: 1, name: "", pageIndex: 0, pageSize: 9999 };
    $scope.welfareType = { 1: "电影票", 2: "充值卡", 3: "优惠券" };
    $scope.searchWelfareList = function () {
        welfare.getWelfareList({}, $scope.search, function (data) {
            if (data.statusCode == 0) {
                $scope.welfareList = data.data.data;
            } else {
                alert(data.statusMessage)
            }
        })
    };
    $scope.welfareEdit = function (item) {
        $state.go("home.welfare.info", { welfareInfo: item, id: item.id, type: "edit" })
    };
    $scope.welfareCreate = function () {
        $state.go("home.welfare.info", { type: "create" })
    };
    $scope.welfareDel = function (item) {
        if (confirm("确定执行该操作吗?")) {
            welfare.deleteWelfare({}, { id: item.id }, function (data) {
                if (data.statusCode == 0) {
                    alert("操作成功!");
                    $scope.searchWelfareList();
                } else {
                    alert(data.statusMessage)
                }
            })
        }
    };
    $scope.welfarePush = function (item) {
        if (confirm("确定执行该操作吗?")) {
            welfare.pushWelfare({}, { id: item.id }, function (data) {
                if (data.statusCode == 0) {
                    alert("操作成功!");
                    $scope.searchWelfareList();
                } else {
                    alert("操作失败!")
                }
            })
        }
    }
    $scope.searchWelfareList();
}]);